package com.xoa.service.event.impl;

import com.xoa.dao.event.TimeLinePostRoleMapper;
import com.xoa.dao.event.TimeLinePostUserMapper;
import com.xoa.model.event.TimeLinePostUser;
import com.xoa.service.event.TimeLinePostUserService;
import com.xoa.util.ToJson;
import com.xoa.util.common.L;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by 张丽军 on 2017/9/1.
 */
@Service
public class TimeLinePostUserServiceImpl implements TimeLinePostUserService{
    @Resource
    TimeLinePostUserMapper timeLinePostUserMapper;

    @Override
    public ToJson<TimeLinePostUser> updateTimeLinePostUser(TimeLinePostUser timeLinePostUser) {
        ToJson<TimeLinePostUser> toJson=new ToJson<>(1,"error");
        try{
            int a=timeLinePostUserMapper.updateTimeLinePostUser(timeLinePostUser);
            if(a>0){
                toJson.setMsg("ok");
                toJson.setFlag(0);
            }else {
                toJson.setMsg("修改失败");
                toJson.setFlag(1);
            }
        }catch (Exception e){
            e.printStackTrace();
            toJson.setMsg(e.getMessage());
            L.e("TimeLinePostUserServiceImpl updateTimeLinePostUser:"+e);
        }
        return toJson;
    }

    @Override
    public ToJson<TimeLinePostUser> addTimeLinePostUser(TimeLinePostUser timeLinePostUser) {
        ToJson<TimeLinePostUser> toJson=new ToJson<>(1,"error");
        try{
            int b=timeLinePostUserMapper.addTimeLinePostUser(timeLinePostUser);
            if(b>0){
                toJson.setMsg("ok");
                toJson.setFlag(0);
            }else {
                toJson.setMsg("新建失败");
                toJson.setFlag(1);
            }
        }catch (Exception e){
            e.printStackTrace();
            toJson.setMsg(e.getMessage());
            L.e("TimeLinePostUserServiceImpl addTimeLinePostUser:"+e);
        }
        return toJson;
    }
}
